import axios from 'axios'
import Bigint from 'json-bigint'
import store from '@/store'
const request = axios.create({
  baseURL: 'http://112.74.99.5:3000/web/api',
  transformResponse: [function (data) {
    try {
      return Bigint.parse(data)
    } catch (error) {
      return data
    }
  }]
})

request.interceptors.request.use(config => {
  const { user } = store.state
  if (user) {
    config.headers.Authorization = `Bearer ${user.token}`
  }
  return config
})
request.interceptors.response.use(config => {
  return config
})
export default request
